home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / funkyjet.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  13KB  |  405 lines

  1. /***************************************************************************
  2.  
  3.   Funky Jet                               (c) 1992 Mitchell Corporation
  4.  
  5.   But actually a Data East game...  Hardware is pretty close to Super Burger
  6.   Time but with a different graphics chip.  And I can't work out the graphics
  7.   format of this chip - it's used in all Data East games from 1991 onwards.
  8.   If you want to help decode it, look at Rohga for an easy example as the fix
  9.   char roms (64k) are in this format.
  10.  
  11.   The game also uses a protection chip which isn't fully worked out yet.
  12.  
  13.   Emulation by Bryan McPhail, mish@tendril.co.uk
  14.  
  15. ***************************************************************************/
  16.  
  17. #include "driver.h"
  18. #include "vidhrdw/generic.h"
  19. #include "cpu/h6280/h6280.h"
  20.  
  21. int  funkyjet_vh_start(void);
  22. void funkyjet_vh_stop(void);
  23. void funkyjet_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  24.  
  25. WRITE_HANDLER( funkyjet_pf2_data_w );
  26. WRITE_HANDLER( funkyjet_pf1_data_w );
  27. READ_HANDLER( funkyjet_pf1_data_r );
  28. READ_HANDLER( funkyjet_pf2_data_r );
  29.  
  30. WRITE_HANDLER( funkyjet_control_0_w );
  31.  
  32. extern unsigned char *funkyjet_pf2_data,*funkyjet_pf1_data,*funkyjet_pf1_row;
  33. static unsigned char *funkyjet_ram;
  34.  
  35. /******************************************************************************/
  36.  
  37. static int loopback[0x800];
  38.  
  39. static WRITE_HANDLER( funkyjet_protection_w )
  40. {
  41.     WRITE_WORD(&loopback[offset],data);
  42.  
  43.     if (offset!=0x502 && offset!=0x700 && offset!=0x70e && offset!=0x78e)
  44.         logerror("CPU #0 PC %06x: warning - write unmapped control address %06x %04x\n",cpu_get_pc(),offset,data);
  45.  
  46.     if (offset==0x10a) {
  47.         soundlatch_w(0,data&0xff);
  48.         cpu_cause_interrupt(1,H6280_INT_IRQ1);
  49.     }
  50.  
  51.     /*
  52.  
  53.         offset==0x502 - written after joystick read
  54.         offset==0x700 - mirror of flipscreen byte
  55.         offset==0x70e - written after credits read
  56.         offset==0x78e - written after credits read
  57.     */
  58. }
  59.  
  60. static READ_HANDLER( funkyjet_protection_r )
  61. {
  62.      switch (offset)
  63.     {
  64.         case 0x148: /* EOR mask for joysticks */
  65.             return 0;
  66.         case 0xc: /* Player 1 & Player 2 joysticks & fire buttons */
  67.         case 0x24c:
  68.             return ~(readinputport(0) + (readinputport(1) << 8));
  69.  
  70.         case 0x2d8: /* EOR mask for credits */
  71.             return 0;
  72.         case 0x778: /* Credits */
  73.             return readinputport(2);
  74.  
  75.         case 0x382: /* DIPS */
  76.             return (readinputport(3) + (readinputport(4) << 8));
  77.  
  78.         case 0x56c:
  79.             return 0;
  80.  
  81.     }
  82.  
  83.     if (offset!=0x778) logerror("CPU #0 PC %06x: warning - read unmapped control address %06x\n",cpu_get_pc(),offset);
  84.  
  85. /*
  86.  
  87. Protection device:
  88.  
  89.     382 is the flag for whether controls are read (bne 0x800)
  90.  
  91.     778 is read and written back to 502
  92.  
  93.  
  94. */
  95.  
  96.     return 0xffff;
  97. }
  98.  
  99. /******************************************************************************/
  100.  
  101. static struct MemoryReadAddress funkyjet_readmem[] =
  102. {
  103.     { 0x000000, 0x07ffff, MRA_ROM },
  104.     { 0x120000, 0x1207ff, paletteram_word_r },
  105.     { 0x140000, 0x143fff, MRA_BANK1 },
  106.     { 0x160000, 0x1607ff, MRA_BANK2 },
  107.     { 0x180000, 0x1807ff, funkyjet_protection_r },
  108.  
  109.     { 0x320000, 0x321fff, funkyjet_pf1_data_r },
  110.     { 0x322000, 0x323fff, funkyjet_pf2_data_r },
  111.     { 0x340000, 0x340bff, MRA_BANK3 },
  112.     { 0x342000, 0x342bff, MRA_BANK4 }, /* pf2 rowscroll */
  113.     { -1 }  /* end of table */
  114. };
  115.  
  116. static struct MemoryWriteAddress funkyjet_writemem[] =
  117. {
  118.     { 0x000000, 0x07ffff, MWA_ROM },
  119.     { 0x120000, 0x1207ff, paletteram_xxxxBBBBGGGGRRRR_word_w, &paletteram },
  120.     { 0x140000, 0x143fff, MWA_BANK1, &funkyjet_ram },
  121.     { 0x160000, 0x1607ff, MWA_BANK2, &spriteram },
  122.     { 0x180000, 0x1807ff, funkyjet_protection_w },
  123.  
  124.     { 0x184000, 0x184001, MWA_NOP },
  125.     { 0x188000, 0x188001, MWA_NOP },
  126.  
  127.     { 0x300000, 0x30000f, funkyjet_control_0_w },
  128.     { 0x320000, 0x321fff, funkyjet_pf1_data_w, &funkyjet_pf1_data },
  129.     { 0x322000, 0x323fff, funkyjet_pf2_data_w, &funkyjet_pf2_data },
  130.     { 0x340000, 0x340bff, MWA_BANK3, &funkyjet_pf1_row },
  131.     { 0x342000, 0x342bff, MWA_BANK4 }, /* pf2 rowscroll */
  132.     { -1 }  /* end of table */
  133. };
  134.  
  135. /******************************************************************************/
  136.  
  137. static WRITE_HANDLER( YM2151_w )
  138. {
  139.     switch (offset) {
  140.     case 0:
  141.         YM2151_register_port_0_w(0,data);
  142.         break;
  143.     case 1:
  144.         YM2151_data_port_0_w(0,data);
  145.         break;
  146.     }
  147. }
  148.  
  149. /* Physical memory map (21 bits) */
  150. static struct MemoryReadAddress sound_readmem[] =
  151. {
  152.     { 0x000000, 0x00ffff, MRA_ROM },
  153.     { 0x100000, 0x100001, MRA_NOP },
  154.     { 0x110000, 0x110001, YM2151_status_port_0_r },
  155.     { 0x120000, 0x120001, OKIM6295_status_0_r },
  156.     { 0x130000, 0x130001, MRA_NOP }, /* This board only has 1 oki chip */
  157.     { 0x140000, 0x140001, soundlatch_r },
  158.     { 0x1f0000, 0x1f1fff, MRA_BANK8 },
  159.     { -1 }  /* end of table */
  160. };
  161.  
  162. static struct MemoryWriteAddress sound_writemem[] =
  163. {
  164.     { 0x000000, 0x00ffff, MWA_ROM },
  165.     { 0x100000, 0x100001, MWA_NOP }, /* YM2203 - this board doesn't have one */
  166.     { 0x110000, 0x110001, YM2151_w },
  167.     { 0x120000, 0x120001, OKIM6295_data_0_w },
  168.     { 0x130000, 0x130001, MWA_NOP },
  169.     { 0x1f0000, 0x1f1fff, MWA_BANK8 },
  170.     { 0x1fec00, 0x1fec01, H6280_timer_w },
  171.     { 0x1ff402, 0x1ff403, H6280_irq_status_w },
  172.     { -1 }  /* end of table */
  173. };
  174.  
  175. /******************************************************************************/
  176.  
  177. INPUT_PORTS_START( funkyjet )
  178.     PORT_START    /* Player 1 controls */
  179.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
  180.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
  181.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
  182.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  183.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
  184.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
  185.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* button 3 - unused? */
  186.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
  187.  
  188.     PORT_START    /* Player 2 controls */
  189.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL )
  190.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL )
  191.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL )
  192.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL )
  193.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
  194.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
  195.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* button 3 - unused? */
  196.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
  197.  
  198.     PORT_START    /* Credits */
  199.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN3 )
  200.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  201.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 )
  202.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK )
  203.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
  204.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
  205.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  206.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  207.  
  208.     PORT_START    /* Dip switch bank 1 */
  209.  
  210.     /* Dips seem inverted with respect to other Deco games */
  211.  
  212.     /* Some of these coinage options may not be correct.. */
  213.     PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Coin_A ) )
  214.     PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
  215.     PORT_DIPSETTING(    0x40, DEF_STR( 2C_1C ) )
  216.     PORT_DIPSETTING(    0xe0, DEF_STR( 1C_1C ) )
  217.     PORT_DIPSETTING(    0x60, DEF_STR( 1C_2C ) )
  218.     PORT_DIPSETTING(    0xa0, DEF_STR( 1C_3C ) )
  219.     PORT_DIPSETTING(    0x60, DEF_STR( 1C_4C ) )
  220.     PORT_DIPSETTING(    0x80, DEF_STR( 1C_5C ) )
  221.     PORT_DIPSETTING(    0x20, DEF_STR( 1C_6C ) )
  222.     PORT_DIPNAME( 0x1c, 0x1c, DEF_STR( Coin_B ) )
  223.     PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
  224.     PORT_DIPSETTING(    0x04, DEF_STR( 2C_1C ) )
  225.     PORT_DIPSETTING(    0x1c, DEF_STR( 1C_1C ) )
  226.     PORT_DIPSETTING(    0x18, DEF_STR( 1C_2C ) )
  227.     PORT_DIPSETTING(    0x14, DEF_STR( 1C_3C ) )
  228.     PORT_DIPSETTING(    0x10, DEF_STR( 1C_4C ) )
  229.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_5C ) )
  230.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_6C ) )
  231.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
  232.     PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
  233.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  234.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
  235.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  236.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  237.  
  238.     PORT_START    /* Dip switch bank 2 */
  239.     PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Lives ) )
  240.     PORT_DIPSETTING(    0x80, "1" )
  241.     PORT_DIPSETTING(    0x00, "2" )
  242.     PORT_DIPSETTING(    0xc0, "3" )
  243.     PORT_DIPSETTING(    0x40, "4" )
  244.     PORT_DIPNAME( 0x30, 0x30, DEF_STR( Difficulty ) )
  245.     PORT_DIPSETTING(    0x10, "Easy" )
  246.     PORT_DIPSETTING(    0x30, "Normal" )
  247.     PORT_DIPSETTING(    0x20, "Hard" )
  248.     PORT_DIPSETTING(    0x00, "Hardest" )
  249.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  250.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  251.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  252.     PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
  253.     PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
  254.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  255.     PORT_DIPNAME( 0x02, 0x02, "Allow Continue" )
  256.     PORT_DIPSETTING(    0x00, DEF_STR( No ) )
  257.     PORT_DIPSETTING(    0x02, DEF_STR( Yes ) )
  258.       PORT_DIPNAME( 0x01, 0x00, DEF_STR( Demo_Sounds ) )
  259.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  260.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  261. INPUT_PORTS_END
  262.  
  263. /******************************************************************************/
  264.  
  265. static struct GfxLayout charlayout =
  266. {
  267.     8,8,    /* 8*8 chars */
  268.     4096,
  269.     4,        /* 4 bits per pixel  */
  270.     { 0x40000*8+8, 0x40000*8, 8, 0 },
  271.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  272.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
  273.     16*8    /* every char takes 8 consecutive bytes */
  274. };
  275.  
  276. static struct GfxLayout tile_layout =
  277. {
  278.     16,16,
  279.     4096,
  280.     4,
  281.     { 0x40000*8+8, 0x40000*8, 8, 0 },
  282.     { 32*8+0, 32*8+1, 32*8+2, 32*8+3, 32*8+4, 32*8+5, 32*8+6, 32*8+7,
  283.         0, 1, 2, 3, 4, 5, 6, 7 },
  284.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
  285.             8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
  286.     64*8
  287. };
  288.  
  289. static struct GfxLayout sprite_layout =
  290. {
  291.     16,16,
  292.     4096*2,
  293.     4,
  294.     { 8, 0, 0x80000*8+8, 0x80000*8 },
  295.     { 32*8+0, 32*8+1, 32*8+2, 32*8+3, 32*8+4, 32*8+5, 32*8+6, 32*8+7,
  296.         0, 1, 2, 3, 4, 5, 6, 7 },
  297.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
  298.             8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
  299.     64*8
  300. };
  301.  
  302. static struct GfxDecodeInfo gfxdecodeinfo[] =
  303. {
  304.     { REGION_GFX1, 0, &charlayout,   256, 16 },    /* Characters 8x8 */
  305.     { REGION_GFX1, 0, &tile_layout,  512, 16 },     /* Tiles 16x16 */
  306.     { REGION_GFX2, 0, &sprite_layout,  0, 16 },    /* Sprites 16x16 */
  307.     { -1 } /* end of array */
  308. };
  309.  
  310. /******************************************************************************/
  311.  
  312. static struct OKIM6295interface okim6295_interface =
  313. {
  314.     1,          /* 1 chip */
  315.     { 7757 },    /* Frequency */
  316.     { REGION_SOUND1 },      /* memory region */
  317.     { 50 }
  318. };
  319.  
  320. static void sound_irq(int state)
  321. {
  322.     cpu_set_irq_line(1,1,state); /* IRQ 2 */
  323. }
  324.  
  325. static struct YM2151interface ym2151_interface =
  326. {
  327.     1,
  328.     32220000/9,
  329.     { YM3012_VOL(45,MIXER_PAN_LEFT,45,MIXER_PAN_RIGHT) },
  330.     { sound_irq }
  331. };
  332.  
  333. static struct MachineDriver machine_driver_funkyjet =
  334. {
  335.     /* basic machine hardware */
  336.     {
  337.          {
  338.             CPU_M68000,
  339.             14000000, /* 28 MHz crystal */
  340.             funkyjet_readmem,funkyjet_writemem,0,0,
  341.             m68_level6_irq,1
  342.         },
  343.         {
  344.             CPU_H6280 | CPU_AUDIO_CPU, /* Custom chip 45 */
  345.             32220000/8, /* Audio section crystal is 32.220 MHz */
  346.             sound_readmem,sound_writemem,0,0,
  347.             ignore_interrupt,0
  348.         }
  349.     },
  350.     58, 529,
  351.     1,
  352.     0,
  353.  
  354.     /* video hardware */
  355.     40*8, 32*8, { 0*8, 40*8-1, 1*8, 31*8-1 },
  356.  
  357.     gfxdecodeinfo,
  358.     1024, 1024,
  359.     0,
  360.  
  361.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE | VIDEO_UPDATE_BEFORE_VBLANK,
  362.     0,
  363.     funkyjet_vh_start,
  364.     funkyjet_vh_stop,
  365.     funkyjet_vh_screenrefresh,
  366.  
  367.     /* sound hardware */
  368.     SOUND_SUPPORTS_STEREO,0,0,0,
  369.       {
  370.         {
  371.             SOUND_YM2151,
  372.             &ym2151_interface
  373.         },
  374.         {
  375.             SOUND_OKIM6295,
  376.             &okim6295_interface
  377.         }
  378.     }
  379. };
  380.  
  381. /******************************************************************************/
  382.  
  383. ROM_START( funkyjet )
  384.     ROM_REGION( 0x80000, REGION_CPU1 ) /* 68000 code */
  385.     ROM_LOAD_EVEN( "jk00.12f", 0x00000, 0x40000, 0x712089c1 )
  386.     ROM_LOAD_ODD ( "jk01.13f", 0x00000, 0x40000, 0xbe3920d7 )
  387.  
  388.     ROM_REGION( 0x10000, REGION_CPU2 )    /* Sound CPU */
  389.     ROM_LOAD( "jk02.16f",    0x00000, 0x10000, 0x748c0bd8 )
  390.  
  391.     ROM_REGION( 0x080000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  392.     ROM_LOAD( "mat02", 0x000000, 0x80000, 0xe4b94c7e ) /* chars */
  393.  
  394.     ROM_REGION( 0x100000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  395.       ROM_LOAD( "mat00", 0x000000, 0x80000, 0xfbda0228 ) /* sprites */
  396.     ROM_LOAD( "mat01", 0x080000, 0x80000, 0x24093a8d )
  397.  
  398.     ROM_REGION( 0x20000, REGION_SOUND1 )    /* ADPCM samples */
  399.       ROM_LOAD( "jk03.15h",    0x00000, 0x20000, 0x69a0eaf7 )
  400. ROM_END
  401.  
  402. /******************************************************************************/
  403.  
  404. GAMEX( 1992, funkyjet, 0, funkyjet, funkyjet, 0, ROT0, "[Data East] (Mitchell license)", "Funky Jet", GAME_NOT_WORKING )
  405.